﻿using System.CodeDom;
using System.Linq;
using Roslyn.Compilers.CSharp;

namespace WeaverCustomTool
{
    public static class NamespaceDeclarationExtensions
    {
        public static CodeNamespace MergeImportsWithRoot(this CodeNamespace @namespace, CompilationUnitSyntax root)
        {
            @namespace.Imports.AddRange(root.Usings.Select(p => new CodeNamespaceImport(p.Name.ToFullString().Trim())).ToArray());
            return @namespace;
        }
    }
}
